home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / particles.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-30  |  1.3 KB  |  66 lines

  1. #ifndef _RTS_PARTICLES_
  2. #define _RTS_PARTICLES_
  3.  
  4. #include <windows.h>
  5. #include <d3dx9.h>
  6. #include <vector>
  7. #include "debug.h"
  8. #include "shader.h"
  9. #include "effect.h"
  10.  
  11. void LoadParticleResources(IDirect3DDevice9 *Dev);
  12. void UnloadParticleResources();
  13.  
  14. struct PARTICLE
  15. {
  16.     D3DXVECTOR3 position, velocity, acceleration;
  17.     float time_to_live;    
  18.     D3DXCOLOR color;
  19.     bool m_dead;
  20. };
  21.  
  22. class PARTICLE_SYSTEM : public EFFECT
  23. {
  24.     public:
  25.         PARTICLE_SYSTEM(IDirect3DDevice9 *Dev);
  26.         ~PARTICLE_SYSTEM();
  27.         void Update(float timeDelta);
  28.         void Render();
  29.         bool isDead();
  30.  
  31.         void RenderBatch(int start, int batchSize);
  32.         void PreRender();
  33.         void PostRender();
  34.         DWORD FtoDword(float f){return *((DWORD*)&f);}
  35.  
  36.         std::vector<PARTICLE*> m_particles;
  37.         IDirect3DTexture9* m_pTexture;        
  38.         DWORD m_blendMode;
  39.         float m_particleSize;
  40. };
  41.  
  42. class MAGIC_SHOWER : public PARTICLE_SYSTEM
  43. {
  44.     public:
  45.         MAGIC_SHOWER(IDirect3DDevice9 *Dev, int noParticles, D3DXVECTOR3 _origin);
  46.         void Update(float timeDelta);
  47.         bool isDead();
  48.     private:
  49.         D3DXVECTOR3 m_origin;
  50. };
  51.  
  52. class SMOKE : public PARTICLE_SYSTEM
  53. {
  54.     public:
  55.         SMOKE(IDirect3DDevice9 *Dev, int noParticles, D3DXVECTOR3 _origin);
  56.         void Update(float timeDelta);
  57.         bool isDead();
  58.         void Kill(){m_dead = true;}
  59.  
  60.     private:
  61.         D3DXVECTOR3 m_origin;
  62.         bool m_dead;
  63.         int m_numAlive;
  64. };
  65.  
  66. #endif